test: add compressed audio socwatch test#1345
test: add compressed audio socwatch test#1345ekurdybx wants to merge 2 commits intothesofproject:mainfrom
Conversation
8a46815 to
70150f4
Compare
c9edb0c to
f1455fb
Compare
b3ad6c8 to
a5626ac
Compare
a5626ac to
0bcbd9a
Compare
Signed-off-by: Emilia Kurdybelska <emiliax.kurdybelska@intel.com>
0bcbd9a to
7883e5c
Compare
028929a to
d2d4f57
Compare
| print(f"Incorrect value: {pc_state} time % was {value}, expected {expected_value}") | ||
| failures += 1 | ||
|
|
||
| return 0 if failures == 0 else 1 |
There was a problem hiding this comment.
It's cool but I think keeping it easier to read would be better.
| return 0 if failures == 0 else 1 | |
| if failures == 0: | |
| return 0 | |
| return 1 |
d2d4f57 to
cc6155f
Compare
Add test that plays mp3 audio using cplay, and check PC states with Socwatch Signed-off-by: Emilia Kurdybelska <emiliax.kurdybelska@intel.com>
cc6155f to
6154da5
Compare
marc-hb
left a comment
There was a problem hiding this comment.
Very clean and easy to read! Minor suggestions below
| with open(pc_states_file, encoding="utf-8") as file: | ||
| for line in file: | ||
| m = pattern.match(line) | ||
| if m: |
There was a problem hiding this comment.
"early return" pattern
| if m: | |
| if not m: | |
| continue |
Same as you already did below but saves a lot more indentation (and mental load).
| print(f"Incorrect value: {pc_state} time % was {value}, expected {expected_value}") | ||
| failures += 1 | ||
|
|
||
| if failures: |
There was a problem hiding this comment.
| if failures: | |
| return failures |
Then you may not want the main script to exit the number of failures too because some values may have special meaning - but for sure this function has nothing better to return than the number of failures.
| pattern = re.compile(r'^PC(\d+)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*$') | ||
| failures = 0 | ||
|
|
||
| with open(pc_states_file, encoding="utf-8") as file: |
There was a problem hiding this comment.
You could move the with open() to the caller and save even more indentation.
|
|
||
|
|
||
| def analyze_pc_states(pc_states_file, expected_results): | ||
| pattern = re.compile(r'^PC(\d+)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*$') |
There was a problem hiding this comment.
Regexps are notoriously cryptic. What really helps in such cases is to give a few input examples in a comment.
| check_cplay_command() | ||
| { | ||
| dlogi "${play_command[@]}" | ||
| if ! "${play_command[@]}"; then |
There was a problem hiding this comment.
Style nit:
| if ! "${play_command[@]}"; then | |
| "${play_command[@]}" || | |
| die ... |
| expected_results="{\"PC10.2\":$pc10_threshold}" | ||
|
|
||
| # Analyze if the % of the time spent in given PC state was as expected | ||
| if python3 "$SCRIPT_HOME"/tools/analyze-pc-states.py "$pc_states_file" "$expected_results"; then |
There was a problem hiding this comment.
chmod a+x analyze-pc-states.py
I'm afraid sof-test is not going to work on Windows anytime soon!
| if python3 "$SCRIPT_HOME"/tools/analyze-pc-states.py "$pc_states_file" "$expected_results"; then | |
| if "$SCRIPT_HOME"/tools/analyze-pc-states.py "$pc_states_file" "$expected_results"; then |
Add test that plays MP3 sound and performs Socwatch analysis to check if dut enters and stays in PC10 state for the expected % of time (default expected value: 80% in PC10.2 state)
Note: this test will only pass when: